package com.autumn.aitraffic.util;

import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Base64;

public class FileUtil {
    public static MultipartFile base64ToMultipartFile(String base64) throws IOException {
        String[] parts = base64.split(",");
        String contentType = parts[0].split(";")[0].split(":")[1];
        byte[] bytes = Base64.getDecoder().decode(parts[1]);
        return new MockMultipartFile("file", "file", contentType, bytes);
    }
}
